/*
============================================================================
 Name        : pd_file.h
 Author      : Jian(raphyer@hotmail.com)
 Version     :
 Copyright   : GPL
 Description : pd_file.h - header file
============================================================================
*/

#ifndef PD_FILE_H
#define PD_FILE_H

#include "dd_define.h"

__DD_BEGIN_DECLS

typedef enum __pd_file_mode {
    PD_FILE_CREATE = 0, 
    PD_FILE_READ,
    PD_FILE_READ_WRITE
} pd_file_mode;


typedef enum __pd_seek_mode {
    PD_FILE_BEGIN = 0, 
    PD_FILE_CURRENT,
    PD_FILE_END
} pd_seek_mode;


typedef struct __pd_file { 
    char dummy;
} pd_file;

pd_file* pd_file_open(const DD_UNICODE* file_name, pd_file_mode mode) ;

void pd_file_close(pd_file* file) ;

int pd_file_read(pd_file* file, void* ptr, DD_INT len) ;

int pd_file_write(pd_file* file, void* ptr, DD_INT len) ;

int pd_file_tell(pd_file* file) ;

/*
* After seek should return the position of current file
* If the seek offset is bigger than the current file' size, just seek to the file end, DON'T auto expand the file' size ;
* If the seek offset is smaller than the 0, just to the file start .
*/
int pd_file_seek(pd_file* file, DD_INT offset, pd_seek_mode mode) ;

int pd_file_flush(pd_file* file) ; 

int pd_file_size(pd_file* file) ;

DD_BOOL pd_file_exist(const DD_UNICODE* file_name) ;

int pd_file_delete(const DD_UNICODE* file_name) ;

__DD_END_DECLS

#endif  /* PD_FILE_H */

/* End of File */
